package com.yjd.comm.borrow.convert;

import java.util.List;

import com.yjd.comm.borrow.enums.CreditorStatusEnum;
import com.yjd.comm.borrow.model.CreditorTransferModel;
import com.yjd.comm.util.DateUtil;

/**
 * <b>description</b>：债权转让数据转换器 <br>
 * <b>time</b>：2014-11-21下午3:25:02 <br>
 * <b>author</b>： ready likun_557@163.com
 */
public class CreditorTransferModelConvert {
	public static CreditorTransferModel convert(CreditorTransferModel model)
			throws Exception {
		if (model != null) {
			model.getStrMap().put("starttime",
					DateUtil.timestampToDateString(model.getStarttime()));
			model.getStrMap().put("oktime",
					DateUtil.timestampToDateString(model.getOktime()));
			model.getStrMap().put(
					"okdate",
					DateUtil.timestampToDateString(model.getOktime(),
							DateUtil.PATTERN_yyyy_MM_dd));
			model.getStrMap().put("transferstarttime",
					DateUtil.timestampToDateString(model.getTransferstarttime()));
			model.getStrMap().put("transferendtime",
					DateUtil.timestampToDateString(model.getTransferendtime()));
			model.getStrMap().put("status",
					CreditorStatusEnum.getDesc(model.getStatus()));
		}
		return model;
	}

	public static List<CreditorTransferModel> convert(
			List<CreditorTransferModel> models) throws Exception {
		if (models == null || models.size() == 0) {
			return models;
		}
		for (CreditorTransferModel model : models) {
			convert(model);
		}
		return models;
	}
}
